package com.xl.controller;

import com.alibaba.fastjson.JSON;
import com.xl.constants.QueueConstants;
import com.xl.entity.Msg;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendMessageController {

    //借助该对象向队列发送消息
    @Autowired
    private SimpMessageSendingOperations simpMessageSendingOperations ;

    @RequestMapping("/send")
    public void send(Msg msg){
        System.out.println("send");
        simpMessageSendingOperations.convertAndSend(QueueConstants.GROUP_ALARM_QUEUE+"/001", JSON.toJSONString(msg));
    }



}
